package com.karrysong.answerapplication;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;

import com.karrysong.answerapplication.beans.DBMaster;
import com.karrysong.answerapplication.utils.LogUtils;

import cn.bmob.v3.Bmob;

public class MyApplication extends Application {

    private static MyApplication instance;
    private static SQLiteDatabase daoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        //初始化bmob后端云
        Bmob.initialize(this, "c53ba72da79e67a25a067a039f6c693a");
        //配置数据库
        setupDatabase();

    }

    /**
     * 配置数据库
     */
    private void setupDatabase() {
        LogUtils.e("onCreate: 配置数据库 ");
        DBMaster dbMaster = new DBMaster(this);
        daoSession = dbMaster.getWritableDatabase();
    }

    public static SQLiteDatabase getDaoInstant() {
        return daoSession;
    }

    public static MyApplication getInstance() {
        return instance;
    }
}
